package xcc.design.demo.strategyRegion;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class PlayerStrategy {
    private List<CallPrice> callpriceList;

    @Autowired
    public PlayerStrategy(List<CallPrice> callpriceList) {
        this.callpriceList = callpriceList;
    }

    public double doCallPrice(double price) {
        double d = 0.00d;
        for (CallPrice callPrice : callpriceList) {
            PriceRegion region = callPrice.getClass().getAnnotation(PriceRegion.class);
            if (region.max() > price && region.min() < price) {
                d = callPrice.callPrice(price);
                break;
            }
        }
        return d;
    }
}
